﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>复制节点</title>
</head>
<body>
    <ul id="myList1"><li>咖啡</li><li>红茶</li></ul>
    <ul id="myList2"><li>开水</li><li>牛奶</li></ul>
    <p id="demo">单击按钮将项目从一个列表复制到另一个列表中</p>
    <button onclick="myFunction()">复制节点</button>
    <script>
        function myFunction() {
            var itm = document.getElementById("myList2").lastChild;
            var cln = itm.cloneNode(true);
            document.getElementById("myList1").appendChild(cln);
        }
    </script>
</body>
</html>